fix: improve upstream request compatibility and body size configuration#64
Open
kiroo92 wants to merge 3 commits intojames-6-23:mainfrom
Open
fix: improve upstream request compatibility and body size configuration#64kiroo92 wants to merge 3 commits intojames-6-23:mainfrom
kiroo92 wants to merge 3 commits intojames-6-23:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves upstream request compatibility and request validation in three areas:
items./v1/responses/compactrequest shaping so it does not send fields rejected by thecompact upstream endpoint.
Changes
1. Fix missing
itemsin tool schemasFiles:
proxy/translator.goproxy/anthropic.goproxy/translator_test.goWhat changed:
sanitizeSchemaForUpstream, which keeps the existing unsupported-schema-key cleanup andalso recursively injects an empty
itemsschema for arrays that declare"type": "array"butomit
"items".Why:
items.upstream refused.
Effect:
tools.
Tests:
itemsis injected in both normal request translation andResponses-body preparation.
2. Make max request body size configurable
Files:
config/config.goconfig/config_test.gomain.gosecurity/validator.goWhat changed:
MaxRequestBodySizeto runtime config.CODEX_MAX_REQUEST_BODY_SIZE_MB.32 MB.security.RequestSizeLimiter.a named default constant.
Why:
payloads fail unnecessarily in deployments that need a higher ceiling.
Effect:
Tests:
3. Fix
/v1/responses/compactrequest shapingFiles:
proxy/handler.goproxy/translator.goproxy/translator_test.goWhat changed:
ResponsesCompactnow usesPrepareCompactResponsesBodyinstead of the genericPrepareResponsesBody.removes auto-injected fields that the compact upstream endpoint does not accept:
includestorestreamWhy:
endpoint but not for
/responses/compact.Effect:
/v1/responses/compactkeeps the normalized input format it needs, while no longer sendingunsupported fields.
Tests:
includeis also stripped for compact requestsDiff Scope
Compared with
james-6-23/main, this PR changes 8 files with 248 insertions and 11 deletions.Validation
Added/updated unit tests in:
config/config_test.goproxy/translator_test.go